# CMakeLists.txt for stage1_2

# 包含 Flex 和 Bison 模块
find_package(FLEX REQUIRED)
find_package(BISON REQUIRED)

# 设置库名称
set(LIBRARY_NAME stage1_2)

# 定义文件生成规则
BISON_TARGET(MyParser iec_bison.yy ${CMAKE_CURRENT_BINARY_DIR}/iec_bison.cc COMPILE_FLAGS "-d")
FLEX_TARGET(MyScanner iec_flex.ll ${CMAKE_CURRENT_BINARY_DIR}/iec_flex.cc COMPILE_FLAGS "--warn")
ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
# 包含目录
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/absyntax)


# 定义源文件
set(SOURCES
        ${BISON_MyParser_OUTPUTS}
        ${FLEX_MyScanner_OUTPUTS}
        create_enumtype_conversion_functions.cc
        stage1_2.cc
)
# 创建静态库
add_library(${LIBRARY_NAME} STATIC ${SOURCES})

# 设置编译选项
target_compile_definitions(${LIBRARY_NAME} PRIVATE -DDEFAULT_LIBDIR="\\\"lib\\\"" -DYY_BUF_SIZE=65536)

# 设置编译标志（如有需要，可以从上一级CMakeLists.txt继承）
target_compile_options(${LIBRARY_NAME} PRIVATE ${COMMON_CXX_FLAGS} ${COMMON_CXX_WARNINGS})

# 将当前文件夹内的头文件包含进来
include_directories(.)

# 清理文件
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${FLEX_OUTPUT};${BISON_OUTPUT};${BISON_HEADER}")
